import {
	mapGetters
} from "vuex"
export default {
	methods: {
		setBadge() {
			// 给tabder购物车添加徽标
			if(this.total!==0){
				uni.setTabBarBadge({
					index: 2,
					text:this.total + ''
				})
			}else{
				return
			}
		}
	},
	computed: {
		...mapGetters(['total'])
	},
	onShow() {
		this.setBadge()
	},
	watch:{
		total:{
			handler(newval,oldval){
				this.setBadge()
				if(newval===0){
					uni.removeTabBarBadge({
						index:2
					})
				}
			}
		}
	},
	
}
